﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;

namespace Kernel
{
    public class ToolBarBase:System.Windows.Forms.ToolStrip,IControlEx
    {
        public ToolBarBase()
            : base()
        {
        }

        protected virtual void UpdateUI()
        {
            foreach( ToolStripButton tsb in this.Items)
            {
                UpdateToolStripImg(tsb);
            }
        }

        public void MyRefresh()
        {
            UpdateUI();
            this.Refresh();
        }

        public void ItemAdd( ToolStripButton tsb)
        {
            UpdateToolStripImg(tsb);
        }

        private void UpdateToolStripImg( ToolStripButton tsb )
        {
            switch (tsb.Tag as string)
            {
                case "Type.Back":
                    tsb.Image = Resource_main.back_alt;
                    break;
                case "Type.Add":
                    tsb.Image = Resource_main.new_doc;
                    break;
                case "Type.Modify":
                    tsb.Image = Resource_main.edit;
                    break;
                case "Type.Del":
                    tsb.Image = Resource_main.delete_2;
                    break;
                case "Type.Save":
                    tsb.Image = Resource_main.save_as;
                    break;
                case "Type.Manage":
                    tsb.Image = Resource_main.gear;
                    break;
                    break;
                case "Type.Print":
                    tsb.Image = Resource_main.printer;
                    break;
                case "Type.Refresh":
                    tsb.Image = Resource_main.refresh__2;
                    break;
                case "Type.File":
                    tsb.Image = Resource_main.library_bookmarked;
                    break;
                case "Type.Item":
                    tsb.Image = Resource_main.menu_item;
                    break;
                case "Type.Document":
                    tsb.Image = Resource_main.document;
                    break;
                    //case "Type.LeftUp":
                    //    tsb.Image = Resource_main.arrow_left_up;
                    //    break;
                    //case "Type.Folder":
                    //    tsb.Image = Resource_main.arrow_left_up;
                    //    break;
                    //case "Type.FileSync":
                    //    tsb.Image = Resource_main.arrow_left_up;
                    //    break;
            }
        }

        #region 实现IControlEx接口
        void IControlEx.Init() { MyRefresh(); }
        void IControlEx.Load() { }
        void IControlEx.Update() { }
        void IControlEx.Save() { }
        bool IControlEx.Updated { get { return false; } }
        #endregion
    }
}
